#include "kernelprivate.h"
#include "mevent.h"

MEvent::~MEvent()
{

}

MEvent::Type MEvent::type() const
{
	return (Type)d_ptr->_type;
}

void MEvent::accept()
{
	d_ptr->_ignore = false;
}

void MEvent::ignore()
{
	d_ptr->_ignore = true;
}

bool MEvent::isAccept() const
{
	return d_ptr->_ignore == false;
}

bool MEvent::operator==(const MEvent &other) const
{
	return d_ptr->_type == other.d_ptr->_type;
}

MEvent::MEvent(MEventPrivate &d, Type type) :
	d_ptr(&d)
{
	d_ptr->_type = type;
	d_ptr->_ignore = false;
}

/*------------------------------------------------------------------*/

MIOEvent::MIOEvent(IOType type) :
	MEvent(*new MIOEventPrivate(this), IO)
{
	d_func()->_io_type = type;
}

MIOEvent::~MIOEvent()
{

}

bool MIOEvent::operator==(const MEvent &other) const
{
	return MEvent::operator==(other) and
		d_func()->_io_type ==
			dynamic_cast<const MIOEvent*>(&other)->d_func()->_io_type;
}

MIOEvent::IOType MIOEvent::ioType() const
{
	return (IOType)d_func()->_io_type;
}

/*------------------------------------------------------------------*/

MPaintEvent::MPaintEvent() :
	MEvent(*new MPaintEventPrivate(this), Paint)
{

}

MPaintEvent::~MPaintEvent()
{

}

/*------------------------------------------------------------------*/

MTimerEvent::MTimerEvent(int id) :
	MEvent(*new MTimerEventPrivate(this), Timer)
{
	d_func()->id = id;
}

MTimerEvent::~MTimerEvent()
{

}

int MTimerEvent::ID() const
{
	return d_func()->id;
}











